<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>市平台财务统计管理</title>
<meta name="decorator" content="default" />
<script src="${ctxStatic}/common/format/formatDate.js"></script>
<style type="text/css">
.minWidth {
	min-width: 177px;
}	
#contentTable td ,#contentTable th{
	text-align: center;
	padding: 1px 20px;
}
</style>
<script type="text/javascript">
	$(document).ready(function() {
		/* $("#area").click(function() {
			var url = "${ctx }/area/areaChoose/areaQu";
			layer.open({
				type : 2,
				title : '',
				shadeClose : true,
				shade : 0.8,
				area : [ '800px', '500px' ],
				content : url
			});
		}); */
		var now = new Date(); //当前日期
		var nowMonth = now.getMonth(); //当前月
        var nowYear = now.getYear(); //当前年
        nowYear += (nowYear < 2000) ? 1900 : 0;
        var oldYear = nowYear-1;     //上一年
		$(document).on("click","#lastMonth",function(){
			debugger;
			var startDate = new Date($("#startDate").val());
			startDate.setMonth(startDate.getMonth()-1);
	        var firstDate = getLastMonthFirstDay(startDate);
			var lastDate = getLastMonthLastDay(startDate);
	        $("#startDate").val(firstDate);
			$("#endDate").val(lastDate);
		})
		$(document).on("click","#thisYear",function(){
			debugger;
			var startDate = new Date($("#startDate").val());
			var firstDate = getFirstDayOfYear(startDate);
			var lastDate = getLastDayOfYear(startDate);
			$("#startDate").val(firstDate);
			$("#endDate").val(lastDate);
		})
		$(document).on("click","#thisMonth",function(){
			var firstDate = getThisMonthFirstDay(now);
			var lastDate = getThisMonthNowDay(new Date());
			$("#startDate").val(firstDate);
			$("#endDate").val(lastDate);
		})
		$(document).on("click","#quarter",function(){
			debugger;
			var startDate = new Date($("#startDate").val());
			var firstDate = getQuarterFirstDay(startDate);
			var lastDate = getQuarterLastDay(startDate);
			$("#startDate").val(firstDate);
			$("#endDate").val(lastDate);
		});
		$("#btnDown").click(function() {
			layer.confirm('确认要导出出入库订单数据吗？', {
				btn : [ '确认', '取消' ]
			}, function() {
				$("#searchForm").attr("action", "${ctx}/report/bsReportPay/exportExcel");
				$("#searchForm").submit();
				layer.msg('正在导出', {icon: 1});
				$("#searchForm").attr("action", "${ctx}/report/bsReportPay/list");
			}, function() {
				
			});
		});
	});
	function page(n, s) {
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
		return false;
	}

	function rese() {//重置
		$("#startDate").val("");
		$("#endDate").val("");
		$("#areaCodeName").val("");
		$("#areaCodeId").val("");
		$("#orderNo").val("");
		$("#payType").val("").select2();
	}
	/* function setReceive(str, code, type, id, parentIds, grade) {
		$("#areaName").val(str);
		$("#areaCode").val(code);
	}
	 */
	/* function deleteOrder(id) {
		layer.confirm('确认要删除此条订单数据吗？', {
			icon: 2, title:'提示', btn : [ '确认', '取消' ]
		}, function() {
			$("#searchForm").attr("action", "${ctx}/order/bsVaccineOrder/delete?id="+id);
			$("#searchForm").submit();
			$("#searchForm").attr("action", "");
			layer.msg('正在删除', {icon: 1});
		}, function() {
			
		});
	}; */
</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/report/bsReportPay/list">出入库账单列表</a></li>
		<shiro:hasPermission name="report:bsReportPay:edit">
			<li><a href="${ctx}/report/bsReportPay/formAdd">建账</a></li>
		</shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="bsReportPay"
		action="${ctx}/report/bsReportPay/list" method="post"
		class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}" />
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}" />
		<%-- <input id="areaCode" name="areaCode" type="hidden" value="${bsReportPay.areaCode}" /> --%>
		<table class="table table-bordered">
			<tr>
				<th>地区</th>
				<td>
					<sys:treeselect2 id="areaCode" name="areaCode" value="${bsReportPay.areaCode}" labelName="areaName" labelValue="${bsReportPay.areaName}"
					title="机构" url="/sys/office/treeData" extId="${office.id}" cssClass="input-medium" allowClear="${office.currentUser.admin}" layer = "true"/>
				</td>
				<%-- <td><input type="text" id="areaName" name="areaName"
					maxlength="255" readonly="readonly" class="input-medium"
					value="${bsReportPay.areaName}" /> <input id="area"
					class="btn btn-primary btn-mini" type="button" value="选 择" /></td> --%>
				<th>类型：</th>
				<td>
					<form:select path="payType" id="payType"
						class="input-medium">
						<form:option value="" label="--请选择--" />
						<form:options items="${fns:getDictList('pay_type')}"
							itemLabel="label" itemValue="value" htmlEscape="false" />
					</form:select>
				</td>
				<th>出入库单号：</th>
				<td>
				    <input type="text" name="orderNo" id="orderNo" class="input-medium" value="${bsReportPay.orderNo}"/>
				</td>
			</tr>
			<tr>
				<th>开始日期:</th>
				<td>
					<input name="startDate" id="startDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});" 
					value='<fmt:formatDate value='${bsReportPay.startDate}' pattern="yyyy-MM-dd" />' />
				</td>
				<th>截至日期:</th>
				<td>
				    <input name="endDate" id="endDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"
					value='<fmt:formatDate value='${bsReportPay.endDate}' pattern="yyyy-MM-dd" />' />
				</td>
				<td colspan="2">
					<input type="button" class="btn btn-primary"  id="lastMonth"    value="上月"/>
					<input type="button" class="btn btn-primary"  id="thisMonth"    value="本月"/>
					<input type="button" class="btn btn-primary"  id="quarter"  value="本季度"/>
                    <input type="button" class="btn btn-primary"  id="thisYear" value="本年度"/>
				</td>
			</tr>
		</table>
		<div>
			<button id="btnSubmit" class="btn btn-primary" type="submit">查询</button>
			<button id="btnReset" class="btn btn-primary" type="button"
				onclick="rese()">重置</button>
			<button id="btnDown" class="btn btn-primary" type="button">导出</button>
		</div>
	</form:form>
	<sys:message content="${message}" />
	<table id="contentTable"
		class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<shiro:hasPermission name="report:bsReportPay:edit"><th>操作</th></shiro:hasPermission>
				<th>收款单位</th>
				<th>欠款/回款  单位</th>
				<th>类型</th>
				<th>金额（欠款/收款）</th>
				<th>日期</th>
				<th>单号</th>
				<th>成本总价</th>
				<th>出库总价</th>
				<th>备注</th>
				<th>创建时间</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page.list}" var="bsReportPay">
				<tr>
					<shiro:hasPermission name="report:bsReportPay:edit"><td>
	    				<a href="${ctx}/report/bsReportPay/formEdit?id=${bsReportPay.id}">修改</a>
						<a href="${ctx}/report/bsReportPay/delete?id=${bsReportPay.id}" onclick="return confirmx('确认要删除该条账单数据吗？', this.href)">删除</a>
					</td></shiro:hasPermission>
					<td>${bsReportPay.supplyorgName}</td>
					<td>${bsReportPay.receiveorgName}</td><td>${fns:getDictLabel(bsReportPay.type, "pay_order_type", "")}/${fns:getDictLabel(bsReportPay.payType, "pay_type", "")}</td>
					<td>${bsReportPay.payment}</td>
					<td><fmt:formatDate value="${bsReportPay.payDate}" pattern="yyyy年MM月dd日" /></td>
					<td>${bsReportPay.orderNo}</td>
					<td>${bsReportPay.sumOrignprice}</td>
					<td>${bsReportPay.sumSellprice}</td>
					<td>${bsReportPay.remarks}</td>
					<td><fmt:formatDate value="${bsReportPay.createDate}" pattern="yyyy年MM月dd日" /></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>